﻿using Sasa.QualityTools.CodeAnalysis.Common;
using System;
using System.IO;

namespace Sasa.QualityTools.CodeAnalysis.Core.Services.CodeAnalysis
{
    internal class FxCopReportValueConverter : IFxCopReportValueConverter
    {
        internal string FxCopProjectPath { get; set; }


        public string ConvertTargetPath(string original)
        {
            if (String.IsNullOrWhiteSpace(FxCopProjectPath))
            {
                return original;
            }

            var directory = original.Replace("$(ProjectDir)", Path.GetDirectoryName(FxCopProjectPath));
            var result = Path.GetFullPath(directory);

            Logger.Info("Converted the assembly path from '{0}' to '{1}'.", original, result);

            return result;
        }
    }
}
